package com.insurance.common.common;


import com.insurance.common.enums.CommonEnum;
import com.insurance.common.enums.CommonProEnum;
import com.insurance.common.enums.CommonResponseEnum;
import com.insurance.common.enums.ResponseEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
 * @version 1.0
 * @date 2020/9/20
 **/
@ApiModel(value = "响应信息")
public class CommonResponseData<T> {

    /**
     * 响应码
      */
    @ApiModelProperty(value = "响应码")
    private String code;

    /**
     * 响应文言
     */
    @ApiModelProperty(value = "响应文言")
    private String msg;

    /**
     * 响应数据
     */
    @ApiModelProperty(value = "响应数据")
    private T data;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public CommonResponseData() {
    }

    public CommonResponseData(String code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> CommonResponseData<T> success(){
        return new CommonResponseData<T>(CommonResponseEnum.SUCCESS.getCode(), CommonResponseEnum.SUCCESS.getMsg(), null);
    }

    public static <T> CommonResponseData<T> success(String code, String msg){
        return new CommonResponseData<T>(code, msg, null);
    }

    public static <T> CommonResponseData<T> success(String code, String msg, T data){
        return new CommonResponseData<T>(code, msg, data);
    }

    public static <T> CommonResponseData<T> success(CommonResponseEnum commonResponseEnum){
        return new CommonResponseData<T>(commonResponseEnum.getCode(), commonResponseEnum.getMsg(), null);
    }

    public static <T> CommonResponseData<T> success(CommonProEnum commonProEnum){
        return new CommonResponseData<T>(commonProEnum.getCode(), commonProEnum.getMsg(), null);
    }
    public static <T> CommonResponseData<T> success(CommonProEnum commonProEnum, T data){
        return new CommonResponseData<T>(commonProEnum.getCode(), commonProEnum.getMsg(), data);
    }

    public static <T> CommonResponseData<T> success(CommonResponseEnum commonResponseEnum, T data){
        return new CommonResponseData<T>(commonResponseEnum.getCode(), commonResponseEnum.getMsg(), data);
    }

    public static <T> CommonResponseData<T> success(T data){
        return new CommonResponseData<T>(CommonResponseEnum.SUCCESS.getCode(), CommonResponseEnum.SUCCESS.getMsg(), data);
    }

    public static <T> CommonResponseData<T> error(){
        return new CommonResponseData<T>(CommonResponseEnum.ERROR.getCode(), CommonResponseEnum.ERROR.getMsg(), null);
    }

    public static <T> CommonResponseData<T> error(T data){
        return new CommonResponseData<T>(CommonResponseEnum.ERROR.getCode(), CommonResponseEnum.ERROR.getMsg(), data);
    }

    public static <T> CommonResponseData<T> error(String code, String message){
        return new CommonResponseData<T>(code, message, null);
    }

    public static <T> CommonResponseData<T> error(CommonResponseEnum commonResponseEnum){
        return new CommonResponseData<T>(commonResponseEnum.getCode(), commonResponseEnum.getMsg(), null);
    }

    public static <T> CommonResponseData<T> error(CommonProEnum commonProEnum){
        return new CommonResponseData<T>(commonProEnum.getCode(), commonProEnum.getMsg(), null);
    }

    public static <T> CommonResponseData<T> error(CommonProEnum commonProEnum, T data){
        return new CommonResponseData<T>(commonProEnum.getCode(), commonProEnum.getMsg(), data);
    }

}
